package org.jeecg.modules.zhima.portal.service.impl;

import org.jeecg.modules.zhima.base.util.RedisKeyUtil;
import org.jeecg.modules.zhima.base.util.RedisUtil;
import org.jeecg.modules.zhima.center.service.*;
import org.jeecg.modules.zhima.portal.domain.HomeContentResult;
import org.jeecg.modules.zhima.portal.service.IGameService;
import org.jeecg.modules.zhima.portal.service.IHomeService;
import org.jeecg.modules.zhima.portal.service.IPlayerRankingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 首页内容管理Service实现类
 * Created by dingzg on 2019/1/28.
 */
@Service
public class HomeServiceImpl implements IHomeService {

    @Autowired
    private ISmsHomeAdvertiseService smsHomeAdvertiseService;
    @Autowired
    private RedisUtil redisUtil;
    @Autowired
    private IGameService gameService;
    @Autowired
    private IPlayerRankingService playerRankingService;

    @Override
    public HomeContentResult content() {
        String key = redisUtil.getKey(RedisKeyUtil.HOME_INDEX);
        if (redisUtil.hasKey(key)){
            return (HomeContentResult)redisUtil.get(key);
        }
        HomeContentResult result = new HomeContentResult();
        //获取首页广告
        result.setAdvertiseList(smsHomeAdvertiseService.getList());
        //商品分类
//        result.setCategories(productCategoryService.listHome());
        //获取推荐品牌
//        result.setBrandList(homeBrandService.getList());
//        //获取秒杀信息
//        result.setHomeFlashPromotion(getHomeFlashPromotion());
        //获取新品推荐
//        result.setNewProductList(homeNewProductService.getList());
        //获取人气推荐
//        result.setHotProductList(homeRecommendProductService.getList());
        //获取推荐专题
//        result.setSubjectList(homeRecommendSubjectService.getList());
        //热门赛事
        result.setGameList(gameService.home());
        result.setRankingList(playerRankingService.home());
        redisUtil.set(key, result);
        return result;
    }

}
